package com.itheima.demo;

import javax.xml.crypto.Data;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo01 {
    public static void main(String[] args) {
        /*Date date1 = new Date();
        System.out.println(date1);//Fri Mar 26 11:02:42 CST 2021

        long date = 1000*60*60;
        Date date2 = new Date(date);
        System.out.println(date2);//Thu Jan 01 09:00:00 CST 1970*/

        /*Date date = new Date();
        long time = date.getTime();
        System.out.println(time);//1616728080444
        System.out.println(time/1000/60/60/24/365);//51
        //date.setTime(time);
        long timeMillis = System.currentTimeMillis();
        date.setTime(timeMillis);//将毫秒值转换了格式
        System.out.println(date);//Fri Mar 26 11:09:35 CST 2021*/

        /*Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
        String format = simpleDateFormat.format(date);
        System.out.println(format);//2021/3/26 上午11:15
        try {
            Date parse = simpleDateFormat.parse(format);
            System.out.println(parse);//Fri Mar 26 11:18:00 CST 2021
        } catch (ParseException e) {
            e.printStackTrace();
        }*/

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        Date date = new Date();
        String format = simpleDateFormat.format(date);
        System.out.println(format);//2021年03月26日 11:21:04
    }
}
